POV-Ray : Newsgroups : povray.general : Output image based on distance to camera? : Re: Output image based on distance to camera? Server Time
30 Jul 2024 04:13:47 EDT (-0400)
  Re: Output image based on distance to camera?  
From: Reactor
Date: 14 Sep 2009 02:00:16
Message: <web.4aaddb72280b0bab74fac1dc0@news.povray.org>
"Paco" <nomail@nomail> wrote:
> I was hoping to create an image where the colour of each pixel is proportional
> to the distance from the camera to the intersecting object.
>
> I figure I can use the trace function to get the intersection distance, but how
> about outputting the image? Is there some flag or something to do this?

If I am understanding you correctly, couldn't it be done with a pigment
function?  You could pre-declare the camera coordinates and make a distance
function:

#declare CamLocationX =  0;
#declare CamLocationY =  5;
#declare CamLocationZ = -5;

#declare fn_CamDist = function{
sqrt(
      (x - CamLocationX)*(x - CamLocationX)
    + (y - CamLocationY)*(y - CamLocationY)
    + (z - CamLocationZ)*(z - CamLocationZ)
  )
}

That gives you the straight line distance from any point to the camera.  To
properly use it with a color_map or other map, you'll need to normalize or
clamp the values between 0 and 1.  The way you'll want to depends on your scene
- you could set a distance at which all objects beyond (or in front of) have a
certain map entry, or apply a different function that allows very distant
objects to approach a max map entry at infinity.

HTH

-Reactor


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.